//
//  HeaderView.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/11.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "HeaderView.h"
#import "CommonMacro.h"
@implementation HeaderView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self addHeadSubView];
    }
    return self;
}

- (void)addHeadSubView
{
    //添加头部背景图片
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT*0.28)];
    bgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"头像背景@2x"]];
//    bgView.backgroundColor = UIColorWithRGBA(277, 188, 151, 1);
    [self addSubview:bgView];
    
    //添加头部那个头像
    UIButton *iconButton = [[UIButton alloc] initWithFrame:CGRectMake(bgView.frame.size.width*0.37, bgView.frame.origin.y+bgView.frame.size.height*0.25, bgView.frame.size.height*0.4, bgView.frame.size.height*0.4)];
    [iconButton setBackgroundImage:[UIImage imageNamed:@"aboutour"] forState:UIControlStateNormal];
    iconButton.layer.cornerRadius = bgView.frame.size.height*0.4/2;
    iconButton.clipsToBounds = YES;
    [self addSubview:iconButton];
    [iconButton addTarget:self action:@selector(enterSetCenter) forControlEvents:UIControlEventTouchUpInside];
    
    //添加名字
    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(bgView.frame.size.width*0.33, iconButton.frame.size.height+iconButton.frame.origin.y+5, iconButton.frame.size.width*1.4, iconButton.frame.size.height*0.4)];
    nameLabel.text = @"Linda";
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.textColor = [UIColor whiteColor];
    [self addSubview:nameLabel];
}

#pragma mark 代理
- (void)enterSetCenter
{
    if ([self.delegate respondsToSelector:@selector(enterSetCenter)]) {
        [self.delegate enterSetCenter];
    }
}
@end
